<!DOCTYPE html>
<html class="um landscape min-width-240px min-width-320px min-width-480px min-width-768px min-width-1024px">
<head>
<title></title>
<meta charset="utf-8">
<meta name="viewport" content="target-densitydpi=device-dpi, width=device-width, initial-scale=1, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<meta name="copyright" content="http://www.appcms.org" />
<link rel="stylesheet" href="skin/base.css">
<link rel="stylesheet" href="skin/form.css">
<link rel="stylesheet" href="skin/btn.css">
<script src="js/zy_control.js"></script>
<script src="js/zy_click.js"></script>
<script src="js/config.js"></script>
<script src="js/common.js"></script>
</head>
<body ontouchstart>
<div id="main" class="box-ver box">
  
  <div id="header">
  	<div class="title">
  		<span class="l icon back" ontouchstart="zy_touch('act')" onclick="uexWindow.close(-1);"></span>
		<span class="txt">注册</span>
	</div>
  </div>
  
  
  <div id="content">
    <div class="form">
    
    <div class="items">
        <div class="item">
            <div class="txt"><input type="text" name="username" id="username" maxlength="20" placeholder="请输入2-20位之间的用户名" /></div>
        </div>
        <div class="item">
            <div class="txt"><input type="password" name="password" id='password' maxlength="20"  placeholder="请输入6-20位之间的登录密码" /></div>
        </div>
        <div class="item">
            <div class="txt"> <input type="text" name="email" id="email" maxlength="30"  placeholder="请输入常用邮箱，用于找回密码" /></div>
        </div>
        <div class="item">
            <div class="txt"> <input type="text" name="nickname" id="nickname"  maxlength="20"  placeholder="请输入2-20位之间的昵称" /></div>
        </div>
    </div>
        
      <div class="btn">
        <div class="button" ontouchstart="zy_touch('down')" onclick="reg('sina');">提交注册</div>
      </div>
    </div>
  </div>
</div>
</body>
<script>
    	zy_init();	
		function reg(){
			var username = $$('username').value;
			if(username.length<2 || username.length >20){
				uexWindow.alert('错误提示', '请输入2-20位之间的用户名~', '关闭');return false;
			}
			var password = $$('password').value;
			if(password.length<6 || password.length >20){
				uexWindow.alert('错误提示', '请输入6-20位之间的登录密码~', '关闭');return false;
			}
			
			var email = $$('email').value;
			var patrn = /^([A-Za-z0-9])(\w)+@(\w)+(\.)(com|com\.cn|net|cn|net\.cn|org|biz|info|gov|gov\.cn|edu|edu\.cn)/;   
		    if(!patrn.exec(email)) {   
		        uexWindow.alert('错误提示', '请填写正确的Email~', '关闭');return false; 
		    }
					
			var nickname = $$('nickname').value;
			if(nickname.length<2 || nickname.length >20){
				uexWindow.alert('错误提示', '请输入2-20位之间的呢称~', '关闭');return false;
			}
			
			var url = app_path+'index.php?m=iapp&c=user&a=reg';
			
			uexXmlHttpMgr.open(1,'post',url,"8000");
			uexXmlHttpMgr.setPostData(1,'0','username',username);
			uexXmlHttpMgr.setPostData(1,'0','password',password);
			uexXmlHttpMgr.setPostData(1,'0','email',email);
			uexXmlHttpMgr.setPostData(1,'0','nickname',nickname);
			uexXmlHttpMgr.send(1);
			uexWindow.toast(1, 5, '提交注册中...', 0);
		}
		
		window.uexOnload = function(type){
			if (!type) {
				uexXmlHttpMgr.onData = function(opId, status, data){
					uexXmlHttpMgr.close(opId);
					uexWindow.closeToast();
					data=JSON.parse(data);
					if (status == 1) {
						if(data['success']=='OK'){
							localStorage['u_id']=data['data']['userid'];
							localStorage['u_nick']=data['data']['nickname'];
							localStorage['u_acctoken']=data['data']['password'];
							localStorage['u_seller']=0;
							
							uexWindow.evaluateScript('login',0,'uexWindow.close(0)');
							uexWindow.evaluatePopoverScript('more','content','oklogin("注册成功")');
							uexWindow.close(-0);
						}else{
							uexWindow.alert('提示',data['msg'],'关闭');
						}
					}else if(status==-1){
						uexWindow.alert('提示','提交超时!','关闭');
					}
				}
			}
		}
    </script>
</html>